// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch
{
	public sealed partial class CompletionContext
	{
		[JsonInclude]
		[JsonPropertyName("boost")]
		public double? Boost { get; set; }

		[JsonInclude]
		[JsonPropertyName("context")]
		public Elastic.Clients.Elasticsearch.Context Context { get; set; }

		[JsonInclude]
		[JsonPropertyName("neighbours")]
		public IEnumerable<Elastic.Clients.Elasticsearch.GeoHashPrecision>? Neighbours { get; set; }

		[JsonInclude]
		[JsonPropertyName("precision")]
		public Elastic.Clients.Elasticsearch.GeoHashPrecision? Precision { get; set; }

		[JsonInclude]
		[JsonPropertyName("prefix")]
		public bool? Prefix { get; set; }
	}

	public sealed partial class CompletionContextDescriptor : SerializableDescriptorBase<CompletionContextDescriptor>
	{
		internal CompletionContextDescriptor(Action<CompletionContextDescriptor> configure) => configure.Invoke(this);
		public CompletionContextDescriptor() : base()
		{
		}

		private double? BoostValue { get; set; }

		private Elastic.Clients.Elasticsearch.Context ContextValue { get; set; }

		private IEnumerable<Elastic.Clients.Elasticsearch.GeoHashPrecision>? NeighboursValue { get; set; }

		private Elastic.Clients.Elasticsearch.GeoHashPrecision? PrecisionValue { get; set; }

		private bool? PrefixValue { get; set; }

		public CompletionContextDescriptor Boost(double? boost)
		{
			BoostValue = boost;
			return Self;
		}

		public CompletionContextDescriptor Context(Elastic.Clients.Elasticsearch.Context context)
		{
			ContextValue = context;
			return Self;
		}

		public CompletionContextDescriptor Neighbours(IEnumerable<Elastic.Clients.Elasticsearch.GeoHashPrecision>? neighbours)
		{
			NeighboursValue = neighbours;
			return Self;
		}

		public CompletionContextDescriptor Precision(Elastic.Clients.Elasticsearch.GeoHashPrecision? precision)
		{
			PrecisionValue = precision;
			return Self;
		}

		public CompletionContextDescriptor Prefix(bool? prefix = true)
		{
			PrefixValue = prefix;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (BoostValue.HasValue)
			{
				writer.WritePropertyName("boost");
				writer.WriteNumberValue(BoostValue.Value);
			}

			writer.WritePropertyName("context");
			JsonSerializer.Serialize(writer, ContextValue, options);
			if (NeighboursValue is not null)
			{
				writer.WritePropertyName("neighbours");
				JsonSerializer.Serialize(writer, NeighboursValue, options);
			}

			if (PrecisionValue is not null)
			{
				writer.WritePropertyName("precision");
				JsonSerializer.Serialize(writer, PrecisionValue, options);
			}

			if (PrefixValue.HasValue)
			{
				writer.WritePropertyName("prefix");
				writer.WriteBooleanValue(PrefixValue.Value);
			}

			writer.WriteEndObject();
		}
	}
}